<template>
  <el-card shadow="always" :body-style="{ padding: '20px' }">
    <!-- 分类静态结构 -->
    <el-form :inline="true">
      <el-form-item label="一级分类" >
        <el-select v-model="categoryStore.c1Id" @change="c1Handler" :disabled="sence!=0">
          <el-option :label="c1.name" :value="c1.id" v-for="(c1,index) in categoryStore.c1List"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select v-model="categoryStore.c2Id" @change="c2Handler" :disabled="sence!=0">
          <el-option :label="c2.name" :value="c2.id" v-for="(c2,index) in categoryStore.c2List"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select v-model="categoryStore.c3Id" :disabled="sence!=0">
          <el-option :label="c3.name" :value="c3.id" v-for="(c3,index) in categoryStore.c3List"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>
  
<script setup lang="ts">
import { ref, onMounted, watch } from "vue";
//获取仓库
import useCategoryStore from '../../stores/category';
let categoryStore = useCategoryStore();
//组件挂载完毕
onMounted(() => {
  //通知pinia仓库发请求，获取一级分类的数据
  categoryStore.getC1List();

});
//接受props
defineProps(['sence'])
const c1Handler = () => {
  categoryStore.getC2List()
}
const c2Handler=()=>{
  categoryStore.getC3List()
}

</script>
  
<style scoped>

</style>